Skip to content

feat: Add PersistentHugr #2080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 14, 2025
Merged

feat: Add PersistentHugr #2080

merged 5 commits into from
May 14, 2025

Conversation

lmondada
Copy link
Contributor

@lmondada lmondada commented Apr 15, 2025

The base of this PR will be moved to main once #2070 has been merged in.

Status: The API and main structs have been defined. Most of the core logic has yet to be implemented.

Status: PR is ready. The trait implementations for HugrView, VerifyPatch and ApplyPatch will be in a separate PR once progress on those is unblocked.

Closes #2096

@lmondada lmondada changed the base branch from main to feat/rewrite-trait April 15, 2025 10:48
@lmondada lmondada force-pushed the feat/persistenthugr branch from 44c3fe9 to 5780cda Compare April 15, 2025 10:49
@lmondada lmondada requested a review from aborgna-q April 15, 2025 10:52
@lmondada lmondada force-pushed the feat/persistenthugr branch from 5780cda to 6659c40 Compare April 17, 2025 13:14
@lmondada lmondada marked this pull request as ready for review April 17, 2025 13:17
@lmondada lmondada requested a review from a team as a code owner April 17, 2025 13:17
@lmondada lmondada force-pushed the feat/persistenthugr branch from 6659c40 to c480927 Compare April 17, 2025 13:23
@lmondada
Copy link
Contributor Author

bus factor considerations: we might want to fold RelRc into Hugr at some point (at least the parts that we care about), but I'd suggest first figuring out what works/if it works before putting efforts into that.

Base automatically changed from feat/rewrite-trait to release-rs-v0.16.0 April 29, 2025 13:20
@lmondada lmondada force-pushed the feat/persistenthugr branch from 7fd00f3 to aa7d5cb Compare April 29, 2025 14:49
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 83.06878% with 64 lines in your changes missing coverage. Please review.

Project coverage is 82.05%. Comparing base (8dbeef7) to head (bcea52c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
hugr-core/src/hugr/persistent/state_space.rs 81.06% 23 Missing and 2 partials ⚠️
hugr-core/src/hugr/persistent.rs 82.11% 21 Missing and 1 partial ⚠️
hugr-core/src/hugr/persistent/resolver.rs 15.00% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2080      +/-   ##
==========================================
+ Coverage   82.03%   82.05%   +0.02%     
==========================================
  Files         230      234       +4     
  Lines       41017    41395     +378     
  Branches    37118    37496     +378     
==========================================
+ Hits        33648    33968     +320     
- Misses       5399     5454      +55     
- Partials     1970     1973       +3     
Flag Coverage Δ
python 85.63% <ø> (ø)
rust 81.68% <83.06%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lmondada lmondada requested review from cqc-alec and removed request for aborgna-q April 29, 2025 15:06
Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks great. Most of my comment are minor ones on the docs ... and some umming and aahing about the name.

@lmondada lmondada changed the base branch from release-rs-v0.16.0 to luca/repl-boundarymap May 4, 2025 15:09
@lmondada
Copy link
Contributor Author

lmondada commented May 4, 2025

Thanks @cqc-alec for the very useful comments, the code is much cleaner now. I think everything should be addressed.

deleted_nodes -> invalidation_set

I've realised in testing that I really do need the full invalidation_set as returned by SimpleReplacement (rather than the restricted set of deleted_nodes that I was using). This is because the output boundary map nu_out refers to the nodes past the output boundary; and thus cannot be modified by another patch.

I was trying to avoid using invalidation_set as it makes it impossible to apply two patches next to one another. I've resolved this by making SimpleReplacement more general in a separate PR, see #2151. EDIT: Done and merged into the release branch. I've temporarily rebased this PR on top of that one, and will undo this once #2151 is merged in.

Waiting before merging

I think I will hold off with merging this in until after the upcoming release: the changes in here are non-breaking and can be part of a future release. This will give me additional flexibility on breaking this API before it is released without requiring a further breaking release.

@lmondada lmondada force-pushed the feat/persistenthugr branch from 972c878 to 14f969a Compare May 6, 2025 07:39
@lmondada lmondada changed the base branch from luca/repl-boundarymap to luca/out-boundary-map May 6, 2025 07:39
@lmondada lmondada force-pushed the feat/persistenthugr branch from 61f1ea2 to 14f969a Compare May 6, 2025 08:01
Base automatically changed from luca/out-boundary-map to release-rs-v0.16.0 May 6, 2025 11:00
@lmondada lmondada requested a review from cqc-alec May 6, 2025 16:11
@lmondada lmondada force-pushed the feat/persistenthugr branch from c109959 to a7729f3 Compare May 6, 2025 16:44
@aborgna-q aborgna-q force-pushed the release-rs-v0.16.0 branch from 56c110c to 9cd24ff Compare May 7, 2025 10:54
Base automatically changed from release-rs-v0.16.0 to main May 7, 2025 11:02
@lmondada lmondada force-pushed the feat/persistenthugr branch from a7729f3 to cb812be Compare May 8, 2025 07:05
@lmondada lmondada enabled auto-merge May 14, 2025 18:56
@lmondada lmondada added this pull request to the merge queue May 14, 2025
Merged via the queue into main with commit aefc96c May 14, 2025
30 checks passed
@lmondada lmondada deleted the feat/persistenthugr branch May 14, 2025 19:04
@hugrbot hugrbot mentioned this pull request May 14, 2025
lmondada added a commit that referenced this pull request May 15, 2025
This was referenced May 29, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jun 3, 2025
## 🤖 New release

* `hugr-model`: 0.20.0 -> 0.20.1
* `hugr-core`: 0.20.0 -> 0.20.1 (✓ API compatible changes)
* `hugr-llvm`: 0.20.0 -> 0.20.1 (✓ API compatible changes)
* `hugr-passes`: 0.20.0 -> 0.20.1 (✓ API compatible changes)
* `hugr`: 0.20.0 -> 0.20.1 (✓ API compatible changes)
* `hugr-cli`: 0.20.0 -> 0.20.1 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

## `hugr-model`

<blockquote>

##
[0.20.0](hugr-model-v0.19.0...hugr-model-v0.20.0)
- 2025-05-14

### New Features

- [**breaking**] Mark all Error enums as non_exhaustive
([#2056](#2056))
- [**breaking**] Bump MSRV to 1.85
([#2136](#2136))
- Export and import entrypoints via metadata in `hugr-model`.
([#2172](#2172))
- Define text-model envelope formats
([#2188](#2188))
- Import CFG regions without adding an entry block.
([#2200](#2200))
- Symbol applications can leave out prefixes of wildcards.
([#2201](#2201))
</blockquote>

## `hugr-core`

<blockquote>

##
[0.20.1](hugr-core-v0.20.0...hugr-core-v0.20.1)
- 2025-06-03

### Bug Fixes

- check well-definedness of DFG wires in validate
([#2221](#2221))
- Check for order edges in SiblingSubgraph::from_node
([#2223](#2223))
- Make SumType::Unit(N) equal to SumType::General([(); N])
([#2250](#2250))
- canonicalize_nodes sometimes mangles the entrypoint
([#2263](#2263))

### New Features

- Add PersistentHugr ([#2080](#2080))
- Add `Type::used_extensions`
([#2224](#2224))
- Add boundary edge traversal in SimpleReplacement
([#2231](#2231))
- Add signature map function for DFGs
([#2239](#2239))
- PersistentHugr implements HugrView
([#2202](#2202))
- PersistentHugr Walker API
([#2168](#2168))
- Hugr::store_with_exts and auto-include in serde_as
([#2280](#2280))

### Refactor

- tidies/readability improvements to PersistentHugr
([#2251](#2251))
- Deprecate ValidationError::ExtensionError
([#2281](#2281))

### Testing

- Ignore miri errors in tests involving `assert_snapshot`
([#2261](#2261))
</blockquote>

## `hugr-llvm`

<blockquote>

##
[0.20.1](hugr-llvm-v0.20.0...hugr-llvm-v0.20.1)
- 2025-06-03

### Bug Fixes

- Make SumType::Unit(N) equal to SumType::General([(); N])
([#2250](#2250))

### Testing

- Add exec tests for widen op
([#2043](#2043))
</blockquote>

## `hugr-passes`

<blockquote>

##
[0.20.1](hugr-passes-v0.20.0...hugr-passes-v0.20.1)
- 2025-06-03

### Bug Fixes

- Dataflow analysis produces unsound results on Hugrs with entrypoint
([#2255](#2255))

### New Features

- LocalizeEdges pass ([#2237](#2237))
</blockquote>

## `hugr`

<blockquote>

##
[0.20.1](hugr-v0.20.0...hugr-v0.20.1)
- 2025-06-03

### Bug Fixes

- Dataflow analysis produces unsound results on Hugrs with entrypoint
([#2255](#2255))
- check well-definedness of DFG wires in validate
([#2221](#2221))
- Check for order edges in SiblingSubgraph::from_node
([#2223](#2223))
- Make SumType::Unit(N) equal to SumType::General([(); N])
([#2250](#2250))
- canonicalize_nodes sometimes mangles the entrypoint
([#2263](#2263))

### New Features

- LocalizeEdges pass ([#2237](#2237))
- Add PersistentHugr ([#2080](#2080))
- Add `Type::used_extensions`
([#2224](#2224))
- Add boundary edge traversal in SimpleReplacement
([#2231](#2231))
- Add signature map function for DFGs
([#2239](#2239))
- PersistentHugr implements HugrView
([#2202](#2202))
- PersistentHugr Walker API
([#2168](#2168))
- Hugr::store_with_exts and auto-include in serde_as
([#2280](#2280))

### Refactor

- tidies/readability improvements to PersistentHugr
([#2251](#2251))
- Deprecate ValidationError::ExtensionError
([#2281](#2281))

### Testing

- Ignore miri errors in tests involving `assert_snapshot`
([#2261](#2261))
</blockquote>

## `hugr-cli`

<blockquote>

##
[0.20.1](hugr-cli-v0.20.0...hugr-cli-v0.20.1)
- 2025-06-03

### New Features

- support external subcommands via PATH
([#1343](#1343))
([#2278](#2278))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add PersistentHugr data structure based on SimpleReplacement
2 participants